package com.hhd.pdf.components;

import com.hhd.pdf.context.GeneratorContext;
import com.itextpdf.text.Element;
import com.itextpdf.text.Phrase;
import com.hhd.pdf.CommonUtils;
import org.dom4j.Attribute;
import org.dom4j.tree.DefaultElement;
import org.springframework.stereotype.Component;

import java.util.Collection;

@Component
public class ImageComponent extends AbstractInlineComponent {
    @Override
    public String getName() {
        return "img";
    }

    @Override
    public String getFormula(DefaultElement defaultElement) {
        Attribute src = defaultElement.attribute("src");
        return src.getValue();
    }

    @Override
    public Collection<? extends Element> createPdfElement(DefaultElement defaultElement,
                                                          GeneratorContext context,
                                                          String parsedFormula) {
        Phrase elements = new Phrase("11");
        elements.setFont(context.getGeneratorParameters().getFont());
        return CommonUtils.newList(elements);
    }
}
